#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

int gcd(int a, int b)
{
    while (a % b)
    {
        int m = a % b;
        a = b;
        b = m;
    }
    return b;
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}